package com.zqwh.xtool.api.online;


import com.zqwh.yj.sdk.utils.httpRequest.beans.HttpResult2;
import com.zqwh.xtool.domain.LendItem;
import com.zqwh.xtool.domain.StockVO;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by eason.yang on 2018/1/19.
 */
public interface StockApi {
    @GET("stock/list/item")
    Observable<HttpResult2<List<LendItem>>> getStock(@Header("Authorization") String token,
                                                     @Query("devId") Long devId,
                                                     @Query("hasRFID") Boolean hasRFID,
                                                     @Query("hasLent") Boolean hasLent);

    /**
     * 初始化工具车
     * @return
     */
    @POST("stock/init")
    @FormUrlEncoded
    Observable<HttpResult2<Object>> initStock(@Header("Authorization") String token,
                                              @Field("devId") Long devId,
                                              @Field("epcs") String epcs,
                                              @Field("toolIds") String toolIds);

    /**
     * 访问库存
     * @return
     */
    @POST("stock/list")
    @FormUrlEncoded
    Observable<HttpResult2<HashMap<String, ArrayList<StockVO>>>> getStockListByDevId(
            @Header("Authorization") String token, @Field("devId") Long devId);

    /**
     * 访问已借出库存
     * @return
     */
    @POST("stock/lent/list")
    @FormUrlEncoded
    Observable<HttpResult2<ArrayList<StockVO>>> getLentStockList(
            @Header("Authorization") String token,@Field("devId") Long devId, @Field("epcs") String epcs, @Field("toolIds") String toolIds);

    /**
     * 访问无RFID工具库存
     * @return
     */
    @POST("stock/norfid/list")
    @FormUrlEncoded
    Observable<HttpResult2<ArrayList<StockVO>>> getNoRfidStockListByDevId(
            @Header("Authorization") String token,@Field("devId") Long devId);

    @PUT("stock/inc")
    Observable<HttpResult2<Object>> incStock(@Header("Authorization") String token,
                                                @Query("devId") Long devId,
                                                @Query("epcs") String incEpcs,
                                                @Query("toolIds") String incToolIds);
    @PUT("stock/red")
    Observable<HttpResult2<Object>> redStock(@Header("Authorization") String token,
                                                @Query("devId") Long devId,
                                                @Query("stockIds") String stockIds);

    @POST("stock/epc-position")
    Observable<HttpResult2<Object>> updateEpcPosition(@Body RequestBody content);
}
